import request from '@/utils/request'

export function getProducts(pageNum, pageSize) {
    return request({
      url: '/production/listData',
      method: 'get',
      params: { pageNum, pageSize }
    })
}



export function saveProduct(data){

    let formData = new FormData()
    if(data.id){
        formData.append('id', data.id)
    }

    formData.append('name', data.name)
    formData.append('brief', data.brief)
    formData.append('belong', data.belong)
    formData.append('imgFile', data.imgFile)
    formData.append('sheetFile', data.sheetFile)

    return request({
        url:'/production/save',
        method:'POST',
        data:formData,
        headers:{
            "Content-Type":'multipart/form-data'
        }
    })
}

export function deleteProduct(id){
    return request({
        url:'/production/delete',
        method:'get',
        params:{id}
    })
}

export function getModels(pageNum, pageSize, productionName) {
    return request({
      url: '/model-series/listData',
      method: 'get',
      params: { pageNum, pageSize , productionName}
    })
}


export function saveModel(data){

    let formData = new FormData()
    if(data.id){
        formData.append('id', data.id)
    }

    formData.append('modelName', data.modelName)
    formData.append('brief', data.brief)
    formData.append('productionName', data.productionName)
    formData.append("params", data.params)
    formData.append('sheetFile', data.sheetFile)

    return request({
        url:'/model-series/save',
        method:'POST',
        data:formData,
        headers:{
            "Content-Type":'multipart/form-data'
        }
    })
}

export function deleteModel(id){
    return request({
        url:'/model-series/delete',
        method:'get',
        params:{id}
    })
}